﻿using System.IO;
using HeadPicture;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Windows.Media.Imaging;
using System.Windows.Media;

namespace TestProject1
{
    
    
    /// <summary>
    ///This is a test class for D301Test and is intended
    ///to contain all D301Test Unit Tests
    ///</summary>
    [TestClass()]
    public class D301Test
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MaskImage
        ///</summary>
        [TestMethod()]
        public void MaskImageTest()
        {
            var d301 = new D301();
            string imageurl = @"http://s5.cr.itc.cn/mblog/icon/2b/c7/12964627512447.gif";
            var url = new Uri(imageurl);
            var decoder = new GifBitmapDecoder(url, BitmapCreateOptions.PreservePixelFormat,
                                   BitmapCacheOption.Default);
            ImageSource imageSource = d301.MaskImage(180, 180, decoder.Frames[0]);
            Assert.IsTrue(imageSource != null);
        }

        /// <summary>
        ///A test for SaveToBmp
        ///</summary>
        [TestMethod()]
        public void SaveToBmpTest()
        {
            D301.SaveToBmp();
            Assert.IsTrue(File.Exists("new.bmp"));
        }
    }
}
